package org.codefinger.dao.impl.sql.ast;

import org.codefinger.dao.impl.SQLVisitor;
import org.codefinger.dao.impl.sql.Expression;

public class IndexLeftLikeExpression implements Expression {

	private int	param;

	public IndexLeftLikeExpression(int param) {
		super();
		this.param = param;
	}

	@Override
	public boolean matchVisit(SQLVisitor visitor) {
		Object obj = visitor.getParam(param);
		if (obj == null) {
			return false;
		}
		visitor.addParam(NamedLeftLikeExpression.getLeftLike(obj.toString()));
		visitor.appendSQL('?');
		return true;
	}

	@Override
	public void visit(SQLVisitor visitor) {
		visitor.addParam(NamedLeftLikeExpression.getLeftLike(String.valueOf(visitor.getParam(param))));
		visitor.appendSQL('?');
	}
	
}
